package com.ruoyi.erecord.locus.task;

import com.ruoyi.erecord.locus.logic.LocusDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

@Slf4j
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling
public class LocusDataTask {

    @Value("${erecord.api.call:true}")
    private boolean callApi;

    @Value("${spring.profiles.active}")
    private String env;

    @Resource
    LocusDataService apiLogService;

    @Scheduled(cron = "0/20 * * * * ?")
    private void getProcess() {
        log.info("start task. env : {}", env);
        if (callApi && "prod".equals(env)) {
            apiLogService.updateProcess();
        }
    }

}
